import os
import json
import numpy as np
from os.path import abspath, join
results = {}

dir_path = abspath(join(__file__, '../result'))

for _, _, files in os.walk(dir_path):
    for filename in files:
        with open(join(dir_path, filename), 'r', encoding='utf8') as f:
            results[filename] = [
                json.loads(each)['result']['perplexity']
                for each in f.readlines()
            ]

for k, v in results.items():
    print(k, ':')
    print('count:', len(v))
    print('mean:', np.mean(v))
    print('std:', np.std(v))
